package org.electrode.task;

public class WaitTask extends PeriodicTask {
	final long wait;
	volatile long start;
	
	
	public WaitTask(long ms) {
		wait = ms;
		reset();
	}
	
	public boolean doWork() {
		long now = System.currentTimeMillis();
		if (0 == start)
			start = now;
		long elapsed = now - start;
		return (elapsed > wait);
	}
	
	public void doReset() {
		start = 0;
	}

	public PeriodicTask copy() {
		return new WaitTask(wait);
	}

}
